# ifndef __Save_H_
# define __Save_H_

bool RequestSave ();
void SaveMap ();
void SaveMapAs ();

class CFileTypeInfo;
void SaveMap (const CFileTypeInfo * _pSaverInfo, const char * _strFileName);

//////////////////////////////////////

# include "FileTypeInfo.h"

class CMapSaver {
  public:
	virtual bool CanSave (const map_t & _map) = 0;
	virtual bool PrepareToSave (const map_t & _map) {return true;}
	virtual bool Save (HANDLE _hFile, const char * _strFileName, const map_t & _map) = 0;
};

# define DECLARE_MAP_SAVER_impl(_T,_strClass,_strExt,_strFilter,_dwFlags) \
	CMapSaver * Create_##_T () {return new _T;} \
	CFileTypeInfo Creator_##_T (NULL, & Create_##_T, _strClass, _strExt, _strFilter, _dwFlags);

# define DECLARE_MAP_SAVER(_T,_strClass,_strExt,_strFilter)         DECLARE_MAP_SAVER_impl (_T, _strClass, _strExt, _strFilter, 0)
# define DECLARE_DEFAULT_MAP_SAVER(_T,_strClass,_strExt,_strFilter) DECLARE_MAP_SAVER_impl (_T, _strClass, _strExt, _strFilter, ftiDefault)
# define DECLARE_MAP_EXPORT(_T,_strClass,_strExt,_strFilter)        DECLARE_MAP_SAVER_impl (_T, _strClass, _strExt, _strFilter, ftiImportExport)

# define DECLARE_WPTRK_EXPORT(_T,_strClass,_strExt,_strFilter)      DECLARE_MAP_SAVER_impl (_T, _strClass, _strExt, _strFilter, ftiImportExport | ftiWTR)

//////////////////////////////////////

struct map_t;
bool CheckVectorData (const map_t & _map);

# endif // __Save_H_